package com.changcheng.project.yuminsi.vo;


import com.changcheng.project.yuminsi.error.GlobalErrorCode;

/**
 * @author yuminsi
 * @description
 * @date 2020/8/20 10:07
 * @since
 */
public class BaseOutput<T> {
    private String code;
    private String description;
    private T data;

    /**
     * 输出信息
     * @param errorCode
     * @param data
     * @return
     */
    public static BaseOutput responseData(GlobalErrorCode errorCode, Object data) {
        BaseOutput baseOutput = new BaseOutput();
        baseOutput.setCode(errorCode.getCode());
        baseOutput.setDescription(errorCode.getDescription());
        baseOutput.setData(data);
        return baseOutput;
    }

    public BaseOutput fail(String code, String description){
        this.code=code;
        this.description=description;
        return this;
    }

    public BaseOutput fail(String code){
        this.code=code;
        this.description=description;
        return this;
    }

    public BaseOutput getData(T data){
        this.data=data;
        return this;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    @Override
    public String toString() {
        return "BaseOutput{" +
                "code='" + code + '\'' +
                ", description='" + description + '\'' +
                ", data=" + data +
                '}';
    }
}
